package cn.yunhe.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;

import cn.yunhe.controller.UserController;
import cn.yunhe.entity.Listuser;

public class UserAction {
	private HttpServletRequest request=ServletActionContext.getRequest();
	private static Logger logger = LogManager.getLogger(UserAction.class);
	
	@Autowired
	private UserController uc;
	
	public String userlogin(){
		String name=request.getParameter("username");
		String pwd=request.getParameter("userpwd");
		Listuser user=new Listuser();
		user.setUsername(name);
		user.setUserpwd(pwd);
		if(uc.login(user)!=null){
			logger.info(user.getUsername()+"登录成功");
			request.getSession().setAttribute("user", user);
			return "success";
		}else{
			logger.warn(user.getUsername()+"登录失败");
			return "fail";
		}
	}
	public String login(){
		return "success";
	}
	public String reg(){
		return "success";
	}
	
}
